import java.util.Scanner;
class Rational{
    private long numerator;//分子
    private long denominator;//分母
    private long integer;//整数
    private boolean negetive=false;//负数
    private boolean isZero=false;//分母为零
    private long totalNumerator;//整数+分子

    public Rational(long n,long d){
        if(d==0){
            isZero=true;
            return;
        }

        if(n<0){
            negetive=!negetive;
        }

        if(d<0){
            negetive=!negetive;
        }

        integer=n/d;
        numerator=n-integer*d;
        denominator=Math.abs(d);

        if(numerator>1||numerator<-1){
            long gcd=cakcGCD(Math.abs(numerator),denominator);
            if(gcd>0){
                numerator/=gcd;
                denominator/=gcd;
            }
        }
        totalNumerator=numerator+integer*denominator;
    }

    private long cakcGCD(long a,long b){
        if(b==0){
            return a;
        }
        return cakcGCD(b,a%b);
    }

    public static long paraseNumerator(String s){
        return Long.parseLong(s.substring(0,s.indexOf('/')));
    }

    public static long paraseDenominator(String s){
        return Long.parseLong(s.substring(s.indexOf('/')+1,s.length()));
    }

    public Rational Add(Rational r){
        long n=totalNumerator*r.denominator+denominator*r.totalNumerator;
        long d=denominator*r.denominator;
        return new Rational(n,d);
    }

    public Rational Sub(Rational r){
        long n=totalNumerator*r.denominator-denominator*r.totalNumerator;
        long d=denominator*r.denominator;
        return new Rational(n,d);
    }

    public Rational Mul(Rational r){
        long n=totalNumerator*r.totalNumerator;
        long d=denominator*r.denominator;
        return new Rational(n,d);
    }

    public Rational Div(Rational r){
        long n=totalNumerator*r.denominator;
        long d=denominator*r.totalNumerator;
        return new Rational(n,d);
    }

    public String toString(){
        StringBuilder s=new StringBuilder();
        if(isZero){
            s.append("Inf");
            return new String(s);
        }
        if(integer==0&&numerator==0){
            s.append("0");
            return new String(s);
        }
        if(negetive){
            s.append("(-");
        }
        if(integer!=0){
            s.append(Math.abs(integer));
            if(numerator!=0){
                s.append(' ');
            }
        }
        if(numerator!=0){
            s.append(Math.abs(numerator));
            s.append('/');
            s.append(denominator);
        }
        if(negetive){
            s.append(')');
        }
        return new String(s);
    }
}
public class demo01 {
    //Rational Arithmetic(有理数运算)
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()){
            String s=sc.next();
            Rational r1=new Rational(Rational.paraseNumerator(s),Rational.paraseDenominator(s));
            s=sc.next();
            Rational r2=new Rational(Rational.paraseNumerator(s),Rational.paraseDenominator(s));
            System.out.println(r1+" + "+r2+" = "+r1.Add(r2));
            System.out.println(r1+" - "+r2+" = "+r1.Sub(r2));
            System.out.println(r1+" * "+r2+" = "+r1.Mul(r2));
            System.out.println(r1+" / "+r2+" = "+r1.Div(r2));
        }
    }
}
